package com.gupaoedu.vip.threadlocal;

/**
 * @Description: 单例模式之ThreadLocal
 * @Author: fuyl
 * @since 2019年03月14日
 * @Version: 1.0
 */
public class ThreadLocalSingleton {

    private ThreadLocalSingleton threadLocalSingleton;

    /** 线程安全 */
    private static final ThreadLocal<ThreadLocalSingleton> tls = new ThreadLocal<ThreadLocalSingleton>() {

        @Override
        protected ThreadLocalSingleton initialValue() {
            return new ThreadLocalSingleton();
        }
    };

    public static ThreadLocalSingleton getInstance() {
        return tls.get();
    }
}

